/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.home.table.editor;

import javax.swing.table.*;
import javax.swing.*;
import java.awt.*;

/**
 *
 * @author vi
 */
public class ColorColumnRendererSCThree extends DefaultTableCellRenderer {

    Color bkgndColor, fgndColor;

    public ColorColumnRendererSCThree(Color bkgnd, Color foregnd) {
        super();
        bkgndColor = bkgnd;
        fgndColor = foregnd;
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
            boolean hasFocus, int row, int column) {
        Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        Integer num = Integer.parseInt(value.toString());
        if (num >= 3) {
            cell.setBackground(bkgndColor);
            cell.setForeground(fgndColor);
        } else {
            if (row % 2 == 0) {
                cell.setBackground(Color.WHITE);
            } else {
                cell.setBackground(Color.decode("#f2f2f2"));
            }
            cell.setForeground(Color.BLACK);
            
        }
        if (isSelected) {
            cell.setBackground(Color.decode("#39698A"));
            cell.setForeground(Color.WHITE);
        }
        return cell;
    }
    
}
